﻿Public Class RestadoCivil

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EestadoCivil)
        Dim estadoCivils As List(Of EestadoCivil) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                estadoCivils = DestadoCivil.SeleccionarTodo(descEmpresa)
                If estadoCivils Is Nothing Then estadoCivils = New List(Of EestadoCivil)
                If DisplaySelect Then estadoCivils.Insert(0, New EestadoCivil("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return estadoCivils
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EestadoCivil)
        Dim estadoCivils As List(Of EestadoCivil) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                estadoCivils = DestadoCivil.SeleccionarXEstado(descEmpresa)
                If estadoCivils Is Nothing Then estadoCivils = New List(Of EestadoCivil)
                If DisplaySelect Then estadoCivils.Insert(0, New EestadoCivil("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return estadoCivils
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pEstadoCivil As EestadoCivil) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DestadoCivil.Añadir(descEmpresa, pEstadoCivil)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pEstadoCivil As EestadoCivil) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DestadoCivil.Editar(descEmpresa, pEstadoCivil)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pEstadoCivil As EestadoCivil) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DestadoCivil.Eliminar(descEmpresa, pEstadoCivil)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
